/**
 ***********************************************************************************************************
 * 
 ***********************************************************************************************************
 * @file RBPlane.h
 ***********************************************************************************************************/

#ifndef __RBPLANE_H__
#define __RBPLANE_H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBPlane.h)
#endif

/***********************************************************************************************************
 * Includes
 ***********************************************************************************************************/
#include "RBVector.h"

/***********************************************************************************************************
 * Forward declarations
 ***********************************************************************************************************/

/***********************************************************************************************************
 * Classes
 ***********************************************************************************************************/


class RBPlane
{
public:
    // For Performance reasons, we suppose that m_Normal is always a Unit vector
    // Plane Equation is Normal * (x,y,z) + Distance = 0


    enum        Side        { PS_NOSIDE = 0, PS_POSITIVE, PS_NEGATIVE };
    enum        Face        { PF_LEFT=0, PF_RIGHT, PF_TOP, PF_BOTTOM, PF_NEAR, PF_FAR, PF_COUNT };

				RBPlane     ();
    virtual    ~RBPlane     ();

    Side        WhichSide   (const float3& point) const;

    // Signed Distance: Used by WhichSide
    float32     GetDistance (const float3& point) const;

    void        Build       (float3 normal, float3 point);

    // Intersect point on plane
    float3      GetIntersection(float3 point);

    float3      Normal;
    float32     Distance;

    static void Normalize   (RBPlane* plane);

};


/***********************************************************************************************************/

#endif // __RBPLANE_H__